POV-Ray : Newsgroups : povray.general : Isosurface, box with transformations : Isosurface, box with transformations Server Time
3 Aug 2024 20:18:03 EDT (-0400)
  Isosurface, box with transformations  
From: StephenS
Date: 22 Oct 2003 08:00:01
Message: <3f967141@news.povray.org>
I would like to blob together several box shapes in an isosurface. The size
and transformations of each box will be output from Moray to help me
visualize where everything is.

The following approach seems to work so far.
Only one shape is used so far. Additional shapes will use an array, like in
sx (start x), and a loop. Shear not add yet. Bounding box not calculated.

My question:
Is there a better way to add the transformations to the individual shapes in
the isosurface.

//start code
camera {
  location  <-0.5, 2.0, -3.0>
  look_at   <0.5, 0.5,  0.0>
  right     x*image_width/image_height
}

light_source {
  0*x
  color rgb <1,1,1>
  translate <-20, 40, -20>
}

#declare sx=array[4]{0,0,0,0}; // start
#declare sy=0;
#declare sz=0;
#declare fx=1; // finish
#declare fy=1;
#declare fz=1;

#declare length_x=(fx-sx[0]);
#declare length_y=(fx-sy);
#declare length_z=(fx-sz);

#declare scx=1; // scale
#declare scy=1;
#declare scz=1;

#declare shxy=0; // shear
#declare shxz=0;
#declare shyx=0;
#declare shyz=0;
#declare shzx=0;
#declare shzy=0;

#declare rx=20; // rotate
#declare ry=0;
#declare rz=0;

#declare tx=0; // translate
#declare ty=0;
#declare tz=0;

#declare f_box = function (x,y,z) {
           max(
             (abs(x-length_x/2+sx[0])-abs(length_x/2)),
             (abs(y-length_y/2+sy)-abs(length_y/2)),
             (abs(z-length_z/2+sz)-abs(length_z/2))
           )
         };

#declare f_scale          = function (x,y,z) {f_box(x/scx,y/scy,z/scz)};
#declare f_rotate_x       = function (x,y,z) {f_scale   (x
,z*sin(radians(rx)) + y*cos(radians(rx)) ,z*cos(radians(rx)) -
y*sin(radians(rx)))};
#declare f_rotate_y       = function (x,y,z)
{f_rotate_x(x*cos(radians(ry)) - z*sin(radians(ry)) ,y ,x*sin(radians(ry)) +
z*cos(radians(ry)))};
#declare f_rotate_z       = function (x,y,z) {f_rotate_y(x*cos(radians(rz))
+ y*sin(radians(rz)) ,-x*sin(radians(rz)) + y*cos(radians(rz)),z)};
#declare f_translate      = function (x,y,z) {f_rotate_z(x-tx,y-ty,z-tz)};
#declare f_isosurface_box = function (x,y,z) {f_translate(x,y,z)};

isosurface {
  function { f_isosurface_box(x,y,z) }
  contained_by { box { -5, 5 } }
  texture { pigment {color red 1} finish{ambient 0.2} }
}
// end code

Stephen


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.